/////////////////////////////////////////////////////////////////////////////
// This file is part of the "Java-DAP" project, a Java implementation
// of the OPeNDAP Data Access Protocol.
//
// Copyright (c) 2007 OPeNDAP, Inc.
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
// License as published by the Free Software Foundation; either
// version 2.1 of the License, or (at your option) any later version.
//
// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
// Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public
// License along with this library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
//
// You can contact OPeNDAP, Inc. at PO Box 112, Saunderstown, RI. 02874-0112.
/////////////////////////////////////////////////////////////////////////////
using System;
using System.Text.RegularExpressions;
using NDODS.DAP.BaseTypes;
using NDODS.DAP.Parser;

namespace NDODS.DAP.Server
{
    /// <summary> This class contains the code for performing relative
    /// operations (RelOps) on BaseTypes. It contains one
    /// heavily overloaded method that is smart enough to figure
    /// out which actual BaseType were passed in and perform (if
    /// appropriate) the RelOp comparison on the 2 types.
    /// 
    /// </summary>
    /// <author>  ndp
    /// </author>
    /// <version>  $Revision: 15901 $
    /// </version>
    public class Operator : ExprParserConstants
    {
        private static bool _Debug = false;

        /// <summary> Performs the Relatove Operation (RelOp) indicated by the
        /// parameter <code>oprtr</code> on the 2 passed BaseTypes if
        /// appropriate.
        /// <p/>
        /// Obviously some type don't compare logically, such as asking if
        /// String is less than a Float. For these non sensical operations
        /// and <code>InvalidOperatorException</code> is thrown.
        /// 
        /// </summary>
        /// <param name="oprtr">The operatoration to perform as defined in <code>
        /// NDODS.DAP.Parser.ExprParserConstants</code>
        /// </param>
        /// <param name="lop">  A BaseType to be used as the left operand.
        /// </param>
        /// <param name="rop">  A BaseType to be used as the right operand.
        /// </param>
        /// <returns> True is the operation evaluates as true, flase otherwise.
        /// </returns>
        /// <throws>  InvalidOperatorException </throws>
        /// <throws>  RegExpException </throws>
        /// <throws>  SBHException </throws>
        /// <seealso cref="NDODS.DAP.Parser.ExprParserConstants">
        /// </seealso>
        public static bool op(int oprtr, BaseType lop, BaseType rop)
        {
            if (lop is DByte)
                return (op(oprtr, (DByte) lop, rop));
            else if (lop is DFloat32)
                return (op(oprtr, (DFloat32) lop, rop));
            else if (lop is DFloat64)
                return (op(oprtr, (DFloat64) lop, rop));
            else if (lop is DInt16)
                return (op(oprtr, (DInt16) lop, rop));
            else if (lop is DInt32)
                return (op(oprtr, (DInt32) lop, rop));
            else if (lop is DString)
                return (op(oprtr, (DString) lop, rop));
            else if (lop is DUInt16)
                return (op(oprtr, (DUInt16) lop, rop));
            else if (lop is DUInt32)
                return (op(oprtr, (DUInt32) lop, rop));
            else if (lop is DURL)
                return (op(oprtr, (DURL) lop, rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }


        private static bool op(int oprtr, DByte lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DFloat32 lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DFloat64 lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DInt16 lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DInt32 lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DString lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DUInt16 lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DUInt32 lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        private static bool op(int oprtr, DURL lop, BaseType rop)
        {
            if (rop is DByte)
                return (op(oprtr, lop, (DByte) rop));
            else if (rop is DFloat32)
                return (op(oprtr, lop, (DFloat32) rop));
            else if (rop is DFloat64)
                return (op(oprtr, lop, (DFloat64) rop));
            else if (rop is DInt16)
                return (op(oprtr, lop, (DInt16) rop));
            else if (rop is DInt32)
                return (op(oprtr, lop, (DInt32) rop));
            else if (rop is DString)
                return (op(oprtr, lop, (DString) rop));
            else if (rop is DUInt16)
                return (op(oprtr, lop, (DUInt16) rop));
            else if (rop is DUInt32)
                return (op(oprtr, lop, (DUInt32) rop));
            else if (rop is DURL)
                return (op(oprtr, lop, (DURL) rop));
            else
                throw new InvalidOperatorException("Binary operations not supported for the type:" + lop.GetType());
        }

        //******************************************************************************************
        //******************************************************************************************
        //******************************************************************************************
        //******************************************************************************************


        private static String opErrorMsg(int oprtr, String lop, String rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return ("Less Than (<) Operator not valid between types" + lop + "and" + rop + ".");

                case ExprParserConstants_Fields.LESS_EQL:
                    return ("Less Than Equal To (<=) Operator not valid between types" + lop + "and" + rop + ".");

                case ExprParserConstants_Fields.GREATER:
                    return ("Greater Than (>) Operator not valid between types" + lop + "and" + rop + ".");

                case ExprParserConstants_Fields.GREATER_EQL:
                    return ("Greater Than Equal To (>=) Operator not valid between types" + lop + "and" + rop + ".");

                case ExprParserConstants_Fields.EQUAL:
                    return ("Equal To (==) Operator not valid between types" + lop + "and" + rop + ".");

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return ("Not Equal To (!=) Operator not valid between types" + lop + "and" + rop + ".");

                case ExprParserConstants_Fields.REGEXP:
                    return ("Regular Expression cannot beevaluated between types" + lop + "and" + rop + ".");

                default:
                    return ("Unknown Operator Requested! RTFM!");
            }
        }


        //******************************************************************************************
        //***                              Byte Vs The World                                 ****
        //------------------------------------------------------------------------------------------

        private static bool op(int oprtr, DByte lop, DByte rop)
        {
            int lval = ((int) lop.Value) & 0xFF;
            int rval = ((int) rop.Value) & 0xFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DFloat32 rop)
        {
            int lval = ((int) lop.Value) & 0xFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DFloat64 rop)
        {
            int lval = ((int) lop.Value) & 0xFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DInt16 rop)
        {
            int lval = ((int) lop.Value) & 0xFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DInt32 rop)
        {
            int lval = ((int) lop.Value) & 0xFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DString rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DUInt16 rop)
        {
            int lval = ((int) lop.Value) & 0xFF;
            int rval = ((int) rop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DUInt32 rop)
        {
            int lval = ((int) lop.Value) & 0xFF;
            long rval = ((long) rop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DByte lop, DURL rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              Float32 Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DFloat32 lop, DByte rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DFloat32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DFloat64 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DString rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DUInt16 rop)
        {
            int rval = ((int) rop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DUInt32 rop)
        {
            long rval = ((long) rop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat32 lop, DURL rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              Float64 Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DFloat64 lop, DByte rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DFloat32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DFloat64 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DString rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DUInt16 rop)
        {
            int rval = ((int) rop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DUInt32 rop)
        {
            long rval = ((long) rop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DFloat64 lop, DURL rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              Int16 Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DInt16 lop, DByte rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DFloat32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DFloat64 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DString rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DUInt16 rop)
        {
            int rval = ((int) rop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DUInt32 rop)
        {
            long rval = ((long) rop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt16 lop, DURL rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              Int32 Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DInt32 lop, DByte rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DFloat32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DFloat64 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DString rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DUInt16 rop)
        {
            int rval = ((int) rop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DUInt32 rop)
        {
            long rval = ((long) rop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lop.Value < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lop.Value <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lop.Value > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lop.Value >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lop.Value == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lop.Value != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DInt32 lop, DURL rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              String Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DString lop, DByte rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DFloat32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DFloat64 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DString rop)
        {
            int cmp;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp < 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.LESS_EQL;

                case ExprParserConstants_Fields.LESS_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp <= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER;

                case ExprParserConstants_Fields.GREATER:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp > 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER_EQL;

                case ExprParserConstants_Fields.GREATER_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp >= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.EQUAL;

                case ExprParserConstants_Fields.EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp == 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.NOT_EQUAL;

                case ExprParserConstants_Fields.NOT_EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp != 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.REGEXP;

                case ExprParserConstants_Fields.REGEXP:
                    if (_Debug)
                        Console.Out.WriteLine("Left Operand: '" + lop.Value + "'  Right Operand: '" + rop.Value + "'");
                    try
                    {
                        return (Regex.IsMatch(lop.Value, rop.Value));
                    }
                    catch (Exception e1)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        throw new RegExpException(e1.Message);
                    }
                    goto default;


                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DUInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DUInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DString lop, DURL rop)
        {
            int cmp;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp < 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.LESS_EQL;

                case ExprParserConstants_Fields.LESS_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp <= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER;

                case ExprParserConstants_Fields.GREATER:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp > 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER_EQL;

                case ExprParserConstants_Fields.GREATER_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp >= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.EQUAL;

                case ExprParserConstants_Fields.EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp == 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.NOT_EQUAL;

                case ExprParserConstants_Fields.NOT_EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp != 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.REGEXP;

                case ExprParserConstants_Fields.REGEXP:
                    if (_Debug)
                        Console.Out.WriteLine("Left Operand: '" + lop.Value + "'  Right Operand: '" + rop.Value + "'");
                    try
                    {
                        return (Regex.IsMatch(lop.Value, rop.Value));
                    }
                    catch (Exception e2)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        throw new RegExpException(e2.Message);
                    }
                    goto default;


                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              UInt16 Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DUInt16 lop, DByte rop)
        {
            int lval = ((int) lop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DFloat32 rop)
        {
            int lval = ((int) lop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DFloat64 rop)
        {
            int lval = ((int) lop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DInt16 rop)
        {
            int lval = ((int) lop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DInt32 rop)
        {
            int lval = ((int) lop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DString rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DUInt16 rop)
        {
            int lval = ((int) lop.Value) & 0xFFFF;
            int rval = ((int) rop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DUInt32 rop)
        {
            int lval = ((int) lop.Value) & 0xFFFF;
            long rval = ((long) rop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt16 lop, DURL rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              UInt32 Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DUInt32 lop, DByte rop)
        {
            long lval = ((long) lop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DFloat32 rop)
        {
            long lval = ((long) lop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DFloat64 rop)
        {
            long lval = ((long) lop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DInt16 rop)
        {
            long lval = ((long) lop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DInt32 rop)
        {
            long lval = ((long) lop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rop.Value);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rop.Value);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rop.Value);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rop.Value);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rop.Value);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rop.Value);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DString rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DUInt16 rop)
        {
            long lval = ((long) lop.Value) & unchecked((int) 0xFFFFFFFFL);
            int rval = ((int) rop.Value) & 0xFFFF;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DUInt32 rop)
        {
            long lval = ((long) lop.Value) & unchecked((int) 0xFFFFFFFFL);
            long rval = ((long) rop.Value) & unchecked((int) 0xFFFFFFFFL);
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    return (lval < rval);

                case ExprParserConstants_Fields.LESS_EQL:
                    return (lval <= rval);

                case ExprParserConstants_Fields.GREATER:
                    return (lval > rval);

                case ExprParserConstants_Fields.GREATER_EQL:
                    return (lval >= rval);

                case ExprParserConstants_Fields.EQUAL:
                    return (lval == rval);

                case ExprParserConstants_Fields.NOT_EQUAL:
                    return (lval != rval);

                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DUInt32 lop, DURL rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        //******************************************************************************************
        //***                              URL Vs The World                                 ****
        //------------------------------------------------------------------------------------------


        private static bool op(int oprtr, DURL lop, DByte rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DFloat32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DFloat64 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DString rop)
        {
            int cmp;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp < 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.LESS_EQL;

                case ExprParserConstants_Fields.LESS_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp <= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER;

                case ExprParserConstants_Fields.GREATER:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp > 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER_EQL;

                case ExprParserConstants_Fields.GREATER_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp >= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.EQUAL;

                case ExprParserConstants_Fields.EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp == 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.NOT_EQUAL;

                case ExprParserConstants_Fields.NOT_EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp != 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.REGEXP;

                case ExprParserConstants_Fields.REGEXP:
                    if (_Debug)
                        Console.Out.WriteLine("Left Operand: '" + lop.Value + "'  Right Operand: '" + rop.Value + "'");
                    try
                    {
                        return (Regex.IsMatch(lop.Value, rop.Value));
                    }
                    catch (Exception e2)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        throw new RegExpException(e2.Message);
                    }
                    goto default;


                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DUInt16 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DUInt32 rop)
        {
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                case ExprParserConstants_Fields.LESS_EQL:
                case ExprParserConstants_Fields.GREATER:
                case ExprParserConstants_Fields.GREATER_EQL:
                case ExprParserConstants_Fields.EQUAL:
                case ExprParserConstants_Fields.NOT_EQUAL:
                case ExprParserConstants_Fields.REGEXP:
                    throw new InvalidOperatorException(opErrorMsg(oprtr, lop.TypeName, rop.TypeName));

                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }

        private static bool op(int oprtr, DURL lop, DURL rop)
        {
            int cmp;
            switch (oprtr)
            {
                case ExprParserConstants_Fields.LESS:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp < 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.LESS_EQL;

                case ExprParserConstants_Fields.LESS_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp <= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER;

                case ExprParserConstants_Fields.GREATER:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp > 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.GREATER_EQL;

                case ExprParserConstants_Fields.GREATER_EQL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp >= 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.EQUAL;

                case ExprParserConstants_Fields.EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp == 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.NOT_EQUAL;

                case ExprParserConstants_Fields.NOT_EQUAL:
                    cmp = String.CompareOrdinal(lop.Value, rop.Value);
                    if (cmp != 0)
                        return (true);
                    else
                        return (false);
                    goto case ExprParserConstants_Fields.REGEXP;

                case ExprParserConstants_Fields.REGEXP:
                    if (_Debug)
                        Console.Out.WriteLine("Left Operand: '" + lop.Value + "'  Right Operand: '" + rop.Value + "'");
                    try
                    {
                        return (Regex.IsMatch(lop.Value, rop.Value));
                    }
                    catch (Exception e2)
                    {
                        //UPGRADE_TODO: The equivalent in .NET for method 'java.lang.Throwable.getMessage' may return a different value. "ms-help://MS.VSCC.v80/dv_commoner/local/redirect.htm?index='!DefaultContextWindowIndex'&keyword='jlca1043'"
                        throw new RegExpException(e2.Message);
                    }
                    goto default;


                default:
                    throw new InvalidOperatorException("Unknown Operator Requested! RTFM!");
            }
        }
    }
}